﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.IoTManagement;

namespace Digitalmes.Model.IoTManagement
{
    /// <summary>
    /// 表计读数
    /// </summary>
	[Table("MeterDataRecord")]

    [Display(Name = "_Model.MeterDataRecord")]
    public class MeterDataRecord : TopBasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._MeterDataRecord._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Device")]
        [Comment("设备")]
        public MeterDevice Device { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Device")]
        [Comment("设备")]
        public long? DeviceId { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Source")]
        [Comment("数据来源")]
        public DataSourceEnum? Source { get; set; }
        [Display(Name = "_Model._MeterDataRecord._CollectStatus")]
        [Comment("采集状态")]
        public CollectStatusEnum? CollectStatus { get; set; }
        [Display(Name = "_Model._MeterDataRecord._IsAbnormal")]
        [Comment("异常标记")]
        public bool? IsAbnormal { get; set; }
        [Display(Name = "_Model._MeterDataRecord._AbnormalReason")]
        [Comment("异常原因")]
        public string AbnormalReason { get; set; }
        [Display(Name = "_Model._MeterDataRecord._CurrentValue")]
        [Comment("当前读数")]
        public decimal? CurrentValue { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Usage")]
        [Comment("本次用量")]
        public decimal? Usage { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Unit")]
        [Comment("单位")]
        public string Unit { get; set; }
        [Display(Name = "_Model._MeterDataRecord._ReadingTime")]
        [Comment("读数时间")]
        public DateTime? ReadingTime { get; set; }
        [Display(Name = "_Model._MeterDataRecord._DataValueType")]
        [Comment("数据类型")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public TagDataTypeEnum? DataValueType { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Parameter")]
        [Comment("数据")]
        public MeterParameter Parameter { get; set; }
        [Display(Name = "_Model._MeterDataRecord._Parameter")]
        [Comment("数据")]
        public long? ParameterId { get; set; }
        [Display(Name = "_Model._MeterDataRecord._ParameterName")]
        [Comment("数据名称")]
        [NotMapped]
        public string ParameterName { get; set; }
        [Display(Name = "_Model._MeterDataRecord._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
